package com.smedi.ismedi.personnel.core.port.adapter.restful;

import com.smedi.ismedi.authority.starter.util.AuthorityUtil;
import com.smedi.ismedi.personnel.api.feign.RemotePersonValidateFeignApi;
import com.smedi.ismedi.personnel.core.application.service.PersonApplicationService;
import com.smedi.ismedi.web.starter.common.ResponseData;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: xulinjun
 * @Date: 2021-6-8 13:31
 */
@Slf4j
@RestController
@AllArgsConstructor
public class PersonValidateController implements RemotePersonValidateFeignApi {
    private final PersonApplicationService personApplicationService;

    private final AuthorityUtil authorityUtil;

    /**
     * {@inheritDoc}
     */
    @Override
    public ResponseData<Boolean> getCheckPersonAvailable(Long personId) {
        return new ResponseData<Boolean>().success(personApplicationService.checkPersonAvailable(personId));
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public ResponseData<Boolean> getCheckPersonIsInternal(Long personId) {
        return new ResponseData<Boolean>().success(personApplicationService.checkPersonIsInternal(personId));
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public ResponseData<Boolean> getCheckPersonIsExternal(Long personId) {
        return new ResponseData<Boolean>().success(personApplicationService.checkPersonIsExternal(personId));
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public ResponseData<Boolean> getCheckHrOrganizationHasPerson(Long hrOrganizationId) {
        authorityUtil.getAccessToken();
        return new ResponseData<Boolean>().success(personApplicationService.checkHrOrganizationHasPerson(hrOrganizationId));
    }
}
